#include "ringbuffer.h"
#include <stdio.h>


ringbuffer::ringbuffer(size_t size):buffer(size)
{
	mBuf = rbuf_new(size);
	if(!mBuf){
		perror("Malloc buffer\n");
	}	
}

ringbuffer::~ringbuffer()
{
	free_buffer();
}

size_t ringbuffer::get_data_size()
{
	return rbuf_can_get(mBuf);
}
size_t ringbuffer::get_free_size()
{
	return rbuf_can_put(mBuf);
}

size_t ringbuffer::write_buffer(const void *data, size_t count)
{
	return rbuf_put(mBuf, data, count);
}
size_t ringbuffer::read_buffer(void *data, size_t count)
{
	return rbuf_get(mBuf, data, count);
}
void ringbuffer::flush_buffer()
{
	return rbuf_flush(mBuf);
}

void ringbuffer::free_buffer()
{
	rbuf_free(mBuf);
}
